<?php
namespace App\Module\User\Controller;

use App\Common\Controller\AbstractController;
use App\Module\User\Request\Child\BindRequest;
use App\Module\User\Request\Child\UpdateRequest;
use App\Module\User\Service\ChildService;
use Hyperf\Di\Annotation\Inject;

class ChildController extends AbstractController{

    /**
     * @Inject()
     * @var ChildService $childService
     */
    private $childService;

    public function search(){
        $pagesize = $this->request->input("pagesize");

        return $this->response->json($this->childService->search($pagesize));
    }

    public function getById(int $id){
        return $this->response->json($this->childService->getById($id));
    }

    public function edit(UpdateRequest $request,int $id){
        return $this->response->json($this->childService->update($request,$id));
    }

    public function bind(BindRequest $request){
        return $this->response->json($this->childService->bind($request));
    }

    public function unbind(int $id){
        return $this->response->json($this->childService->unbind($id));
    }
}